Page({
  data:{
    url: ''
  },
  
  onLoad: function (options) {
    let webviewUrl = '';
    console.log(" 网页跳转的协议 options:  ",options)
    // miniUrl 的参数带的是需要跳转的网址，其他的是url的get中的参数。
    if (options && (options.miniUrl || options.url)) {
      webviewUrl = options.miniUrl || options.url;
      let getParam = ''
      for (var key in options) {
        if (key !== 'miniUrl' && key !== "subject"){   
          getParam = getParam + key + "=" + encodeURIComponent(decodeURIComponent(options[key]))+"&";
        }
      }
      let preParam = "?";
      if (options.param  == 2){
        preParam = "#";
      }
      if(getParam){
        webviewUrl = webviewUrl + preParam + getParam +"miniprogram=1";
      }
      var whites = getApp().golbalData.whiteList;
      let isWhiteHost = false
      for(var item in whites){
        if (webviewUrl && webviewUrl.indexOf(item)){
          isWhiteHost = true;
          break;
        }
      }
     
      if (webviewUrl.indexOf("https") === -1){
        webviewUrl.replace('http', 'https');
      }
      // 白名单功能暂时不上
      isWhiteHost = true;
      if (isWhiteHost){
        console.log("@@ webviewUrl：  "+webviewUrl);
        this.setData({
          url: webviewUrl
       })
      }else{
        wx.showToast({
          title: '小程序暂不支持该业务',
          duration: 3000,
        })
      }
    }else{
      wx.showToast({
        title: '小程序暂不支持该业务',
        duration: 3000,
      })
    }
  },

  onShareAppMessage: function (res) {
    let url = this.data.url;
    url = url.replace("?","&");
    return {
      title: '同花顺智能投顾',
      path: '/pages/webview/webview?url=' + getApp().golbalData.indexurl
    }
  }
  })